<template>
  <div class="back-wrapper">
    <div class="back-box color-white flex-h">
      <div class="left">
        <div v-hide>
          <div class="backs" v-show="hasBack" @click="goback">
            <i class="imgIcon"></i>
            <span class="backTxt">返回</span>
          </div>
        </div>
      </div>
      <div class="center flex1">
        <slot name="my-center"></slot>
      </div>
      <div class="right" @click="$emit('btnclick')"><slot name="my-right"></slot></div>
    </div>
  </div>
</template>

<script>
import ls from 'store2'
export default {
  props: {
    goUrl: String,
    hasBack: {
      type: Boolean,
      default: true,
    },
  },
  data() {
    return {}
  },
  mounted() {},
  methods: {
    goback() {
      if (this.goUrl) {
        this.$router.replace({
          path: this.goUrl,
        })
      } else {
        this.$router.back()
      }
    },
  },
}
</script>

<style scoped lang="less">
.back-box {
  width: 7.5rem;
  height: 0.8rem;
  line-height: 0.8rem;
  padding: 0 0.3rem;
  box-sizing: border-box;
  z-index: 10000;
  position: relative;
  .left,
  .right {
    width: 1.2rem;
  }
  .left {
    .backs {
      width: 1.2rem;
    }
    .imgIcon,
    .backTxt {
      vertical-align: middle;
      display: inline-block;
    }
    .backTxt {
      margin-left: 0.1rem;
      font-weight: bold;
      color: #222;
    }
  }
  .right {
    text-align: right;
    padding-top: 0.1rem;
    box-sizing: border-box;
  }
  .center {
    text-align: center;
    font-size: 0.36rem;
    font-family: PingFangSC;
    font-weight: 600;
    color: rgba(34, 34, 34, 1);
  }
  .imgIcon {
    width: 0.4rem;
    height: 0.4rem;
    display: inline-block;
    background: url('~@/static/sprite/icon_sprites_40.png') -0.1rem -0.1rem;
    background-size: 3rem 2.4rem;
  }
}
.color-white {
  background: #fff;
}
</style>
